/*
 *  Packet.h
 *  TubeTruck
 *
 *  Created by Aeturnum on 5/21/08.
 *  Copyright 2008 __MyCompanyName__. All rights reserved.
 *
 */

#pragma once

#include <vector>
#include <map>
#include <assert.h>
#include <exception>

#include "TubeTruckTypes.h"
#include "serialization.h"
#include "unserialization.h" 
#include "smartalloc_wrap.h"
#include "Signiture.h"
#include "util.h"

namespace TTP {
   
   class Packet : public Serializable {
   protected:
      uint32_t mVersionNumber;
      id_hash mIdHash;
      byte mPacketType;
      
      enum{length_idHash = 4};
      
      
   public:
      enum{Packet_OHAI = 0, Packet_IIS = 1, Packet_CANHAS = 2, Packet_LAWL = 3, Packet_DOWANT = 4, Packet_CHEEZBURGER = 5,
           Packet_NOWAI = 6, Packet_HASFLAVR = 7};
      
      Packet();
      Packet(byte);
      Packet(id_hash, byte);
      ~Packet();
      
      // accessors
      byte getType() const;
      uint32_t getVersionNumber() const;
      
      // idHash
      virtual void setSourceIdHash(id_hash);
      virtual id_hash getSourceIdHash() const;
      virtual void setDestIdHash(id_hash);
      virtual id_hash getDestIdHash() const;
      
      //inherited
      virtual void fromVec(std::vector<byte>::const_iterator &vit, 
            const std::vector<byte>::const_iterator &end);
      virtual void toVec(std::vector<byte> &vec) const;
   };
      
}
